package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.domain.OrderInfo;
import com.ruoyi.order.domain.dto.OrderInfoPageDTO;
import com.ruoyi.order.domain.vo.OrderInfoVO;
import com.ruoyi.order.domain.vo.OrderManualPayDTO;
import com.ruoyi.order.service.IOrderInfoService;
import com.ruoyi.server.domain.ServerTask;
import com.ruoyi.server.service.IServerTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单Controller
 *
 * @author ghostmen
 * @date 2024-11-03
 */
@Validated
@RestController
@RequestMapping("/order/info")
@Api(value = "订单管理", tags = "订单管理接口")
public class OrderInfoController extends BaseController {

    @Autowired
    private IOrderInfoService orderInfoService;
    @Autowired
    private IServerTaskService serverTaskService;

    /**
     * 区服任务下拉列表
     */
    @PreAuthorize("@ss.hasPermi('order:info:getServerTaskList')")
    @GetMapping("/getServerTaskList")
    @ApiOperation(value = "区服任务下拉列表")
    public TableDataInfo getServerTaskList() {
        List<ServerTask> list = serverTaskService.getServerTaskList();
        return getDataTable(list);
    }

    /**
     * 查询订单列表
     */
    @PreAuthorize("@ss.hasPermi('order:info:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询订单列表")
    public TableDataInfo list(OrderInfoPageDTO pageDTO) {
        startPage();
        PageInfo<OrderInfoVO> list = orderInfoService.selectOrderInfoList(pageDTO);
        return getDataTable(list);
    }


    /**
     * 获取订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:info:query')")
    @GetMapping(value = "/{orderId}")
    @ApiOperation(value = "获取订单详细信息")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
        return success(orderInfoService.selectOrderInfoByOrderId(orderId));
    }


    /**
     * 手动支付
     */
    @PreAuthorize("@ss.hasPermi('order:info:manualPay')")
    @PostMapping(value = "/manualPay")
    @ApiOperation(value = "手动支付")
    public AjaxResult manualPay(@Valid @RequestBody OrderManualPayDTO payDTO) {
        return toAjax(orderInfoService.manualPay(payDTO));
    }

}
